import axios from 'axios'
// import {lStorage} from '@/utils/storage' 

axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'

const service = axios.create({
  baseURL: process.env.VUE_APP_DOMAIN_URL,
  timeout: 30000
})

// request拦截器
service.interceptors.request.use(config => {
  // 是否需要设置 token
//   let t = lStorage.get('userInfo')
//   if (t) {
//     config.headers['Authorization'] = t['token']
//   }
  return config
}, error => {
  Promise.reject(error)
})

// 响应拦截器
service.interceptors.response.use(res => {
//   if (res.data) {
    return res.data
//   } else {
//     lStorage.remove()
//     return null
//   }
},
error => {
  return Promise.reject(error)
}
)
export default service
